from pygame.transform import smoothscale

from config import win_size

from libs.fun import center_x , center_y , center , create_image_alpha


class ZDisplay ( object ) :
    def __init__ ( self , father , size = win_size ) :
        super ( ZDisplay , self ).__init__ ( )
        self.father = father
        image = create_image_alpha ( "libs/image/alpha.png" )
        self.image = smoothscale ( image , size )
        self.rect = self.image.get_rect ( )
        self._pos = self.rect.topleft

    def draw ( self ) :
        self.father.surface.blit ( self.image , self._pos )

    def update ( self , event , keys , m_keys , m_pos ) :
        pass

    def center_x ( self ) :
        self._pos = center_x ( self.father._size , self._size , self._pos )

    def center_y ( self ) :
        self._pos = center_y ( self.father._size , self._size , self._pos )

    def center ( self ) :
        self._pos = center ( self.father._size , self._size )

    @property
    def _size ( self ) :
        return self.rect.size

    @_size.getter
    def _size ( self ) :
        return self.rect.size

    @_size.setter
    def _size ( self , size ) :
        self.rect.size = size

    @property
    def _pos ( self ) :
        return self.rect.topleft

    @_pos.getter
    def _pos ( self ) :
        return self.rect.topleft

    @_pos.setter
    def _pos ( self , pos ) :
        self.rect.topleft = map ( lambda (a , b ) : a + b , zip ( self.father._pos , pos ) )
